home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
news
/
readers
/
skim-0.8
/
skim-0
/
skim-0.8.4
/
RebuildArticleIndexes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-18
|
4KB
|
130 lines
/*
* NAME
* RebuildArticleIndexes.c
* DESCRIPTION
* Rebuild all of skim's article indexes.
* COPYRIGHT
* Skim - Off-line news reading package optimized for slow lines.
* Copyright (C) 1996 Rene W.J. Pijlman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* VERSION
* Skim version 0.8.4.
*/
#include <dirent.h>
#include "VarBuf.h"
#include "Skim.h"
#include "SkimUtils.h"
#include "StandardIO.h"
FILE_ID("$Header: /home/rene/sys/CVS_MasterSourceRepository/skim/RebuildArticleIndexes.c,v 1.5 1996/02/17 22:47:35 rene Exp $" );
int main( int argc, char ** argv )
{
StandardIO ArticleIndex = SIOCreate();
VarBuf NewsGroup = VBCreate();
VarBuf ArticleDirectoryName = VBCreate();
VarBuf ArticleFileName = VBCreate();
VarBuf ArticleNumber = VBCreate();
VarBuf IndexFileName = VBCreate();
struct dirent * DirectoryEntry;
DIR * ArticleDirectory;
if ( argc != 1 )
{
SIOPrintf( StandardError, "RebuildArticleIndexes\n" );
exit( EXIT_FAILURE );
}
VBPrintf( ArticleDirectoryName, "%s/Art", SkimDirectory() );
ArticleDirectory = opendir( VBAsString(ArticleDirectoryName) );
if ( ArticleDirectory == NULL )
{
SIOPrintf( StandardError, "Error opening directory %s\n",
VBAsString(ArticleDirectoryName) );
exit( EXIT_FAILURE );
}
while ( ( DirectoryEntry = readdir( ArticleDirectory ) ) != NULL )
{
/* Skip "." and "..", and possibly other dot files as well. */
if ( DirectoryEntry->d_name[0] != '.' )
{
char * LastDot = NULL;
char * p;
for ( p = DirectoryEntry->d_name;
*p != '\0';
p++ )
{
if ( *p == '.' )
{
LastDot = p;
}
}
if ( LastDot == NULL )
{
SIOPrintf( StandardError,
"Incorrect file name: %s\n",
DirectoryEntry->d_name );
exit( EXIT_FAILURE );
}
for ( p = DirectoryEntry->d_name; p < LastDot; p++ )
{
VBAppendCharacter( NewsGroup, *p );
}
for ( p = LastDot + 1; *p != '\0'; p++ )
{
VBAppendCharacter( ArticleNumber, *p );
}
VBPrintf( IndexFileName,
"%s/Indexes/Articles/%V",
SkimDirectory(), NewsGroup );
VBPrintf( ArticleFileName, "%V/%s",
ArticleDirectoryName, DirectoryEntry->d_name );
SIOFileOpenVB( ArticleIndex, IndexFileName, OpenModeAppend );
AddArticleToIndex( ArticleFileName, ArticleNumber, ArticleIndex );
SIOFileClose( ArticleIndex );
VBReset( NewsGroup );
VBReset( ArticleFileName );
VBReset( ArticleNumber );
VBReset( IndexFileName );
}
}
(void)closedir( ArticleDirectory );
VBDestroy( NewsGroup );
VBDestroy( ArticleDirectoryName );
VBDestroy( ArticleFileName );
VBDestroy( ArticleNumber );
VBDestroy( IndexFileName );
SIODestroy(ArticleIndex);
return EXIT_SUCCESS;
}